#include <iostream>
using namespace std;
 
int main()
{
    int n = 0, res = 0;
    string str;
    cin >> n >> str;
    int cnt0 = 0, cnt1 = 0;
    for(int i = 0; i < n; ++i)
    {
        if(str[i] == '0')
            ++cnt0;
        else
            ++cnt1;
    }
    if(cnt0 % 2 != 0 || cnt1 % 2 != 0)
    {
        cout << 0 << endl;
        return 0;
    }
    cnt0 /= 2, cnt1 /= 2;
    int left = 0, right = 0;
    int tmp0 = 0, tmp1 = 0;
    while(right < n - 1)
    {
        if(str[right] == '0')
            ++tmp0;
        else
            ++tmp1;
        while(right - left + 1 > n / 2) // 下面注释的出窗口逻辑错了
        {
            if(str[left++] == '0')
                --tmp0;
            else
                --tmp1;
        }
        if(right - left + 1 == n / 2) // 注释掉也行，但有点怪
        {
            if(tmp0 == cnt0 && tmp1 == cnt1)
                res += 2;
        }
        ++right;
    }
    /*
    while(right < n - 1)
    {
        if(str[right] == '0')
            ++tmp0;
        else
            ++tmp1;
        while(left < n && right - left + 1 == n / 2 && tmp0 == cnt0 && tmp1 == cnt1)
        {
            //cout << tmp0 << " " << tmp1 << endl;
            //cout << left << " " << right << endl;
            res += 2;
            if(str[left++] == '0')
                --tmp0;
            else
                --tmp1;
        }
        ++right;
    }
    */
    cout << res << endl;
    return 0;
}